<?php
include('top.php');
require_once('pasmy/dbwaarden.php');
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db, $mysql_id);

/*foreach($_POST as $key => $value) {
	echo "sleutel = $key en waarde = $value<br>";
	}*/
	
	
if(isset($_POST["opwaarderen"])) {

$datum = $_POST["datum"];
$d1 = explode("-",$datum);
$waardb = "vnzvrn" . $d1[0];
$ref = addslashes($_POST["ref"]);$ref = strtoupper($ref);
$client = addslashes($_POST["client"]);$client = strtolower($client);$client = ucwords($client);
$expediteur = addslashes($_POST["exp"]);$expediteur = strtolower($expediteur);$expediteur = ucwords($expediteur);
$bestemmeling = addslashes($_POST["best"]);$bestemmeling = strtolower($bestemmeling);$bestemmeling = ucwords($bestemmeling);
$plaats = addslashes($_POST["ville"]);$plaats = strtolower($plaats);$plaats = ucwords($plaats);
$laadplaats = addslashes($_POST["laadplaats"]);$laadplaats = strtolower($laadplaats);$laadplaats = ucwords($laadplaats);
$colis = addslashes($_POST["colis"]);
$pal = addslashes($_POST["pal"]);
$mp = addslashes($_POST["mp"]);
$poids = addslashes($_POST["poids"]);
$prijs = addslashes($_POST["prix"]);
$opmerkingen = addslashes($_POST["opm"]);
$driver = addslashes($_POST["driver"]);
//$week = addslashes($_POST["week"]);
$record = addslashes($_POST["id"]);
$prijs=number_format($prijs,2);
$cmr=addslashes($_POST["cmr"]);
$nrpl = $_POST["camion"];
$gasoil = $_POST["diesel"];


$sqql = "select ligne from nummerplaten where nrpl = '$nrpl'";
$ress = mysql_query($sqql, $mysql_id);
while ($row = mysql_fetch_row($ress)) {
	$ligne = $row[0];
}

echo "datum = $datum<br>";
$datu = explode("-",$datum);
$date = mktime(0, 0, 0, $datu[1], $datu[2], $datu[0]); 
$week = (int)date('W', $date);

echo "week is $week<br>";






/*foreach($_POST as $key => $value) {
	echo "sleutel = $key en waarde = $value<br>";
	}*/
$sql = "UPDATE $waardb set datum='$datum',ref='$ref',client='$client',expediteur='$expediteur',bestemmeling='$bestemmeling',plaats=
'$plaats',colis='$colis',pal='$pal',mp='$mp',poids='$poids',prijs='$prijs',opmerkingen='$opmerkingen',driver='$driver',week='$week',laadplaats='$laadplaats',cmr='$cmr',gasoil='$gasoil',nrpl='$nrpl',ligne='$ligne' 
 WHERE record = '$record'";
 
if($_SESSION['login'] == "0") {
echo "<strong>sql = $sql</strong><br>";
}

$res = mysql_query($sql, $mysql_id);


?>
<br /><br /><h1><div style="text-align: center">Update done</div></h1>
<form action="zoeken2.php" method="POST">
<div style="text-align: center"><input type="hidden" name="zoek" value="ja" /><input type="submit" name="verder" value="Continuer" /></div>
</form>
<?php

}	
else {
$id = $_GET["nr"];
$waardb = $_GET["jaren"];
//echo "en de zoekterm = $_SESSION[zoekterm]<br>";
/*foreach($_POST as $key => $value) {
	echo "sleutel = $key en waarde = $value<br>";
	}*/
	

$sql = "select lang from chauffeurs";
$res = mysql_query($sql, $mysql_id);
$teller = 0;
while ($row = mysql_fetch_row($res)) {
		$drivers[$teller] = $row[0];
		$teller++;
	}

$sql = "select * from $waardb where record = '$id'";
$res = mysql_query($sql, $mysql_id);
?>
<form action="pdt.php" method="POST">
<table width="40%">
<?php
while ($row = mysql_fetch_row($res)) {
	
	echo "<tr><td width='20%'><strong>Datum</strong></td><td width='20%'><input type='text' size='40' name='datum' value=" . '"' . $row[0] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Reference</strong></td><td width='20%'><input type='text' size='40' name='ref' value=" . '"' . $row[1] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>CMR</strong></td><td width='20%'><input type='text' size='40' name='cmr' value=" . '"' . $row[16] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Client</strong></td><td width='20%'><input type='text' size='40' name='client' value=" . '"' . $row[2] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Expediteur</strong></td><td width='20%'><input type='text' size='40' name='exp' value=" . '"' . $row[3] .'"' . "></td></tr>\n";
	
	echo "<tr><td width='20%'><strong>Laadplaats</strong></td><td width='20%'><input type='text' size='40' name='laadplaats' value=" . '"' . $row[15] .'"' . "></td></tr>\n";
	
	
	echo "<tr><td width='20%'><strong>Destinataire</strong></td><td width='20%'><input type='text' size='40' name='best' value=" . '"' . $row[4] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Ville</strong></td><td width='20%'><input type='text' size='40' name='ville' value=" . '"' . $row[5] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Colis</strong></td><td width='20%'><input type='text' size='40' name='colis' value=" . '"' . $row[6] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Palettes</strong></td><td width='20%'><input type='text' size='40' name='pal' value=" . '"' . $row[7] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Metres planche</strong></td><td width='20%'><input type='text' size='40' name='mp' value=" . '"' . $row[8] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Poids</strong></td><td width='20%'><input type='text' size='40' name='poids' value=" . '"' . $row[9] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Prix</strong></td><td width='20%'><input type='text' size='40' name='prix' value=" . '"' . $row[10] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Gasoil</strong></td><td width='20%'><input type='text' size='40' name='diesel' value=" . '"' . $row[17] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Remarques</strong></td><td width='20%'><input type='text' size='40' name='opm' value=" . '"' . $row[11] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Chauffeur</strong></td><td width='20%'><input type='text' size='40' name='driver' value=" . '"' . $row[12] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Camion</strong></td><td width='20%'><input type='text' size='40' name='camion' value=" . '"' . $row[18] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'><strong>Semaine</strong></td><td width='20%'><input type='text' size='40' name='week' value=" . '"' . $row[13] .'"' . "></td></tr>\n";
	echo "<tr><td width='20%'></td>&nbsp;<td width='20%'><input type='hidden' name='id' value=" . '"' . $row[14] .'"' . "></td></tr>\n";
	
}



?>
<tr><td colspan="2"><br /><input type="hidden" name="komvanpdt" value="ja" /> <div style="text-align: center"><input type="submit" name="opwaarderen" value="Updaten" /></div></td></tr>
</table>
</form>

<?php
}
include('footer.php');
?>